package com.song.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.song.service.FeignService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author TonySong
 * @date 2024/5/9 0009
 * @time 14:56
 */
@RestController
public class TwoController {

    @Resource
    private FeignService feignService;
    @Value("${server.port}")
    private String port;

    @SentinelResource(blockHandler = "getMess")
    @GetMapping("/service2")
    public String service1() {
       return this.feignService.service1();
    }

    public String  getMes(){
        return "对不起，熔断了，请求的服务正在维护中....";
    }

    public String  getMess(BlockException e){
        return "对不起，blockHandler熔断了，请求的服务正在维护中....";
    }
}
